package com.lagou.task;

public class Test01 {

    public static void main(String[] args) {
        // 大写字母、小写字母、数字、其它字符的个数并打 印出来
        String str = "ABCD123!@#$%ab";

        int length = str.length();
        int capitalLetterNum = 0;
        int lowerLetterNum = 0;
        int digitNum = 0;
        int other = 0;

        for (int i = 0;i < length;i++) {

            String s = str.substring(i, i + 1);
            if (s.matches("[A-Z]")) {
                capitalLetterNum++;
            } else if (s.matches("[a-z]")) {
                lowerLetterNum++;
            } else if (s.matches("[0-9]")) {
                digitNum++;
            } else {
                other++;
            }
        }

        System.out.println("大写字母个数为: " + capitalLetterNum);
        System.out.println("小写字母个数为: " + lowerLetterNum);
        System.out.println("数字的个数为: " + digitNum);
        System.out.println("其他字符的个数为:" + other);

    }
}
